// 富文本替换函数
CKEDITOR.replace("editor");

let comment = [
    '1',
  '1',
  '1',
  '1',
  '1',
  '1',
  '1','1','1',

  '1',
  '1',
  '1',
  '1',
  '1',
  '1','1',
  '1',
];

// 游戏测评分页函数
layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
      , layer = layui.layer;

  let comment = comment;

  // 评论区分页
  laypage.render({
    elem: 'gameCommentPagination',
    count: comment.length,
    //自定义首页、尾页、上一页、下一页文本
    first: '首页',
    last: '尾页',
    prev: '<em>上一页</em>',
    next: '<em>下一页</em>',
    // 调颜色
    theme: '#1E9FFF',

    jump: function(obj){
      // 模拟渲染
      document.getElementById('gameComments').innerHTML = function(){
        var arr = []
            , thisComment = comment.concat().splice(obj.curr * obj.limit - obj.limit, obj.limit);
        layui.each(thisComment, function(index, item){
          arr.push('<li><div class="layui-card"><div class="layui-row">'+
              '<div class="layui-card-header"><span>'+item+ '</span>' +
              '<span style="float: right">'+'16L'+'&nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="layui-btn layui-btn-xs">评论</button></span></div></div>' +
              '<div class="layui-card-body" style="border-width: 0 0 1px 0;border-style: solid;border-color: #ececec;">'+ item+'</div></div></li>');
        });
        return arr.join('');
      }();
    }
  });

});
